/*
 * Created by LiuYou on 2020/12/23.
 *
 */

#include <iostream>
#include <memory>
#include <queue>
#include <algorithm>
#include "Pcb.hpp"


int main() {
    std::cout << "====================[ process schedule ]====================" << std::endl;

    std::queue<std::shared_ptr<Pcb>> readyQueue;
    std::queue<std::shared_ptr<Pcb>> runningQueue;
    std::queue<std::shared_ptr<Pcb>> terminalQueue;
    std::cout << "输入测试进程的数目N: ";
    int pcbNum;
    std::cin >> pcbNum;


    std::vector<std::shared_ptr<Pcb>> pcbVector;
    for (int i = 0; i < pcbNum; ++i) {
        std::cout << "输入进程名以及进程所需要的时间T: ";
        std::string processName;
        int processNeedExecutionTime;
        std::cin >> processName >> processNeedExecutionTime;
        std::shared_ptr<Pcb> pcb(std::make_shared<Pcb>(processName, processNeedExecutionTime));
        pcbVector.push_back(pcb);
    }

    std::sort(std::begin(pcbVector), std::end(pcbVector),
              [](const std::shared_ptr<Pcb>& lhs, const std::shared_ptr<Pcb>& rhs) -> bool {
                  return lhs->getNeedExecutionTime() < rhs->getNeedExecutionTime();
              });
    for (const auto& item : pcbVector) {
        readyQueue.push(item);
    }

    for (const auto& item : pcbVector) {
        std::cout << *item << std::endl;
    }


    return 0;
}